package net.airtheva.uniqueTask4.fragment;

import net.airtheva.uniqueTask4.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

public class LyricSearchDialog extends DialogFragment {

	public static final String TAG = "LyricSearchFragment";
	
	public static final String KEY_ARTIST = "artist";
	public static final String KEY_TITLE = "title";
	
	DialogInterface.OnClickListener mOnPositiveClickListener;
	DialogInterface.OnClickListener mOnNegativeClickListener;
	
	EditText mArtist;
	EditText mTitle;
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		
		Bundle args = getArguments();
		
		AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
		
		b.setTitle(TAG);
		
		View view = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_lyric_search, null);
		
		mArtist = (EditText) view.findViewById(R.id.fragment_lyric_search_artist);
		mTitle = (EditText) view.findViewById(R.id.fragment_lyric_search_title);
		
		mArtist.setText(args.getString(KEY_ARTIST, ""));
		mTitle.setText(args.getString(KEY_TITLE, ""));
		
		b.setView(view);
		b.setPositiveButton("Load", mOnPositiveClickListener);
		b.setNegativeButton("Cancel", mOnNegativeClickListener);
		
		AlertDialog ad = b.create();
		
		return ad;
	}
	
	public void SetPositiveClick(DialogInterface.OnClickListener l) {
		
		mOnPositiveClickListener = l;
		
	}

	public void SetNegativeClick(DialogInterface.OnClickListener l) {
		
		mOnNegativeClickListener = l;
		
	}

	public String GetArtist() {
		return mArtist.getText().toString();
	}
	
	public String GetTitle() {
		return mTitle.getText().toString();
	}
	
}
